//package com.cloud.controller;
//
//
//import com.cloud.constent.Constant;
//import com.cloud.newRibbonImpl.NewRibbon;
//import org.springframework.cloud.client.ServiceInstance;
//import org.springframework.cloud.client.discovery.DiscoveryClient;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.client.RestTemplate;
//
//import javax.annotation.Resource;
//import java.util.List;
//
//@RestController
//public class OrderController {
//
//
//    /**
//     * 远程调用模板
//     */
//    @Resource
//    RestTemplate restTemplate;
//
//    @Resource
//    DiscoveryClient discoveryClient;//服务发现工具
//
//    @Resource
//    NewRibbon newRibbon;
//
//    @RequestMapping(value = "order/payment/creat")
//    public CommonResult<Payment> create(@RequestBody Payment payment) {
//        return restTemplate.postForObject(Constant.PAYMENTURL + Constant.PAYMENTURLINSERTCONTROLLER, payment, CommonResult.class);
//    }
//
//
//    @RequestMapping(value = "order/payment/select/{id}")
//    public CommonResult<Payment> select(@PathVariable Long id) {
//        return restTemplate.getForObject(Constant.PAYMENTURL + Constant.PAYMENTURLSELECTCONTROLLER+id, CommonResult.class);
//    }
//
//    @RequestMapping(value = "order/payment/selectEntity/{id}")
//    public CommonResult selectEntity(@PathVariable Long id) {
//        ResponseEntity<CommonResult> entity =restTemplate.getForEntity(Constant.PAYMENTURL + Constant.PAYMENTURLSELECTCONTROLLER+id, CommonResult.class);
//        if(entity.getStatusCode().is2xxSuccessful()){
//            System.out.println(entity.getStatusCode());
//            return entity.getBody();
//        }
//        return null;
//    }
//
//    @RequestMapping(value = "order/payment/balance")
//    public String balance() {
//        List<ServiceInstance> list = discoveryClient.getInstances(Constant.PAYMENServiceName);
//        String uri =  newRibbon.serviceInstance(list).getUri().toString();
//        return uri;
//
//    }
//
//
//}
